package springboot.springboot06_ssmp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import springboot.springboot06_ssmp.entity.HomeNumber;
import springboot.springboot06_ssmp.mapper.HomeNumberMapper;
import springboot.springboot06_ssmp.service.IHomeNumberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author daiqiang
 * @since 2024-01-17
 */
@Service
public class HomeNumberServiceImpl extends ServiceImpl<HomeNumberMapper, HomeNumber> implements IHomeNumberService {

    @Resource
    private HomeNumberMapper homeNumberMapper;




    @Override   //分页，模糊查询
    public IPage<HomeNumber> getPage(int currentPage, int pageSize, HomeNumber homeNumber) {
        LambdaQueryWrapper<HomeNumber> lqw = new LambdaQueryWrapper<>();
        lqw.like(Strings.isNotEmpty(homeNumber.getName()),HomeNumber::getName,homeNumber.getName());
        lqw.like(Strings.isNotEmpty(homeNumber.getCard()),HomeNumber::getCard,homeNumber.getCard());
        lqw.like(Strings.isNotEmpty(homeNumber.getPhonenumber()),HomeNumber::getPhonenumber,homeNumber.getPhonenumber());

        IPage page = new Page(currentPage,pageSize);
        homeNumberMapper.selectPage(page,lqw);
        return  page;

    }

}
